package com.sky.blog.controller;

import com.sky.blog.service.BlogTopicService;
import com.sky.blog.util.ApplicationContextUtils;
import com.sky.blog.vo.Results;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author sky  2022/3/27
 * @version 1.0
 */

@Slf4j
@Api(tags = "博客基本", value = "BlogController")
@RequestMapping("blog")
@RestController
public class BlogController {


    @Resource
    private BlogTopicService topicService;


    @GetMapping("focus/list")
    public Results getFocusList(@RequestParam(value = "n", defaultValue = "3") int n) {
        return Results.SUCCESS.data(topicService.getManyBlogTopics(n));
    }

    @GetMapping("name")
    public Results getApplicationName() {
        String appName = ApplicationContextUtils.getAppProperty("spring.application.name");
        return Results.SUCCESS.data(appName);
    }
}
